package com.java.multipledatasource.spring.batis;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Proxy;

/**
 * @author huxb
 * @date 2020/10/18 0018 下午 6:23
 * @Desciption
 */
public class LuBanFactory {
    public static Object getMapper(Class clazz) {
        /**
         * ClassLoader loader,
         * Class<?>[] interfaces,
         * InvocationHandler h
         */
        ClassLoader classLoader = LuBanFactory.class.getClassLoader();
        Class[] classes = new Class[]{clazz};
        LuBanInvocationHandler luBanInvocationHandler = new LuBanInvocationHandler();
        Object o = Proxy.newProxyInstance(classLoader, classes, luBanInvocationHandler);
        return  o;
    }
}
